/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rafkind.raytracer;

/**
 *
 * @author drafkind
 */
public class Box extends Intersection {
  private Vector3 corner1;
  private Vector3 corner2;

  public Box() {
  }

  public Vector3 getCorner1() {
    return corner1;
  }

  public void setCorner1(Vector3 corner1) {
    this.corner1 = corner1;
    reckonPlanes();
  }

  public Vector3 getCorner2() {
    return corner2;
  }

  public void setCorner2(Vector3 corner2) {
    this.corner2 = corner2;
    reckonPlanes();
  }

  private void reckonPlanes() {
    if (corner1 != null && corner2 != null) {
      getObjects().clear();
      double minX = Math.min(corner1.getData()[0], corner2.getData()[0]);
      double maxX = Math.max(corner1.getData()[0], corner2.getData()[0]);
      double minY = Math.min(corner1.getData()[1], corner2.getData()[1]);
      double maxY = Math.max(corner1.getData()[1], corner2.getData()[1]);
      double minZ = Math.min(corner1.getData()[2], corner2.getData()[2]);
      double maxZ = Math.max(corner1.getData()[2], corner2.getData()[2]);

      
      getObjects().add(new Plane(new Vector3(0, 1, 0), minY));
      //getObjects().add(new Plane(new Vector3(0, -1, 0), maxY));

      getObjects().add(new Plane(new Vector3(1, 0, 0), minX));
      getObjects().add(new Plane(new Vector3(-1, 0, 0), maxX));

      //getObjects().add(new Plane(new Vector3(0, 0, 1), maxZ));
      //getObjects().add(new Plane(new Vector3(0, 0, -1), minZ));
    }
  }
}